import request from '@/utils/request'
import axios from 'axios'

// 获取类型
export function listCatalogType(data) {
  // return request({
  //   method: 'post',
  //   url: '/layers/listCatalogType',
  //   data: data
  // })

  return axios({
    method: 'get',
    url: './catalog.json'
  })
}

// 根据类型获取目录树 typeId
export function treeByTypeId(treeType) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/tree?type=${treeType}`
  })
}
// 根据类型获取目录树treeType specialType
export function treeByTypeIdSpecialType(
  treeType,
  specialType
) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/tree?type=${treeType}&&specialType=${specialType}`
  })
}

// 根据类型获取目录树 specialType
export function treeBySpecialType(specialType) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/tree?type=${specialType}`
  })
}

// 驾驶舱目录树新增
export function treeAdd(data) {
  return request({
    method: 'post',
    url: '/resource/datacatalog/add',
    data
  })
}
// 驾驶舱目录树编辑
export function treeUpdate(data, pikd) {
  return request({
    method: 'put',
    url: `/resource/datacatalog/update/${pikd}`,
    data: data
  })
}

// 驾驶舱目录树删除
export function treeDelete(pkid) {
  return request({
    method: 'delete',
    url: `/resource/datacatalog/delete?pkid=${pkid}`
  })
}

// 驾驶舱目录树服务资源查询
export function serviceQuery(params) {
  return request({
    method: 'get',
    url: '/resource/datacatalog/service/query',
    params
  })
}

// 新增目录树下属数据服务
export function serveAdd(data) {
  return request({
    method: 'post',
    url: '/resource/datacatalog/service/add',
    data
  })
}

// 目录树下数据服务编辑
export function serveEdit(data, pikd) {
  return request({
    method: 'put',
    url: `/resource/datacatalog/service/update/${pikd}`,
    data: data
  })
}

// 目录树下数据服务删除
export function serveDelete(pkid) {
  return request({
    method: 'delete',
    url: `/resource/datacatalog/service/delete?pkid=${pkid}`
  })
}

// 服务统计配置新增
export function statisticsAdd(data) {
  return request({
    method: 'post',
    url: '/resource/datacatalog/service/config/add',
    data
  })
}
// 服务统计配置查询
export function statisticsQuery(params) {
  return request({
    method: 'get',
    url: '/resource/datacatalog/service/config/query',
    params
  })
}

// 范围上传 shp

export function mapParseGeojson(type, data) {
  return request({
    method: 'post',
    url: `/map/map/parse/${type}/geojson`,
    data
  })
}

// 根据专题列表类型查询统计服务图层
export function treeByTopic(treeType) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/service/showchart/query?specialType=${treeType}`
  })
}

// 数据服务专题默认新增
export function serviceDefaultAdd(data) {
  return request({
    method: 'post',
    url: '/resource/special/service/add',
    data
  })
}
// 数据服务专题默认删除
export function serviceDefaultDelete(params) {
  return request({
    method: 'DELETE',
    url: '/resource/special/service/delete',
    params
  })
}
// 数据专题类型默认服务拖动排序
export function topicDefaultMove(data) {
  return request({
    method: 'put',
    url: '/resource/special/service/move',
    data: data
  })
}
// 专题默认服务列表
export function topicDefaultList(type) {
  return request({
    method: 'GET',
    url: `/resource/special/service/query?specialType=${type}`
    // data: data
  })
}
// 专题服务目录服务挂载
export function serviceTopicAdd(data) {
  return request({
    method: 'post',
    url: '/resource/datacatalog/service/special/add',
    data
  })
}
// 专题服务目录服务移除
export function serviceTopicDelete(params) {
  return request({
    method: 'DELETE',
    url: '/resource/datacatalog/service/special/delete',
    params
  })
}
// 数据专题已选择服务列表查询
export function treeBySpecial(type) {
  return request({
    method: 'get',
    url: `resource/datacatalog/tree/checked?type=${type}`
  })
}

// 校验服务可删除状态
export function checkServiceDelete(serviceId) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/file/check/service?serviceId=${serviceId}`
  })
}

// 校验地图服务可删除状态
export function checkMapServiceDelete(mapServiceId) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/file/check/map/service?mapServiceId=${mapServiceId}`
  })
}

// 校验数据服务可删除状态
export function checkDataServiceDelete(dataServiceId) {
  return request({
    method: 'get',
    url: `/resource/datacatalog/file/check/data/service?dataServiceId=${dataServiceId}`
  })
}
